[PATCH] output/http: log content-type like other headers
authorPhilippe Antoine <pantoine@oisf.net>
Thu, 30 Oct 2025 10:43:27 +0000 (11:43 +0100)
committerAndreas Dolp <dev@andreas-dolp.de>
Wed, 10 Dec 2025 19:12:20 +0000 (20:12 +0100)
Ticket: 8056

Avoid stack allocation.
Do not handle null and ; especially

(cherry picked from commit b8411fcc8dfc16910c3080d4d8c03a9a64c3a1f7)

Origin: upstream, https://github.com/OISF/suricata/commit/4b1d284bb57219b6677a8bda5cdc14a24a6aa22d.patch
Bug: https://redmine.openinfosecfoundation.org/issues/8056
Subject: Upstream fix for CVE-2025-64333

Gbp-Pq: Name CVE-2025-64333.patch

src/output-json-http.c

index 5f44e955573d3084e525b852052a5c76a5eae9d1..c58c32fd017a51137f431c80068cd79f810775c4 100644 (file)
@@ -237,13 +237,12 @@ static void EveHttpLogJSONBasic(JsonBuilder *js, htp_tx_t *tx)
     if (tx->response_headers != NULL) {
         htp_header_t *h_content_type = htp_table_get_c(tx->response_headers, "content-type");
         if (h_content_type != NULL) {
-            const size_t size = bstr_len(h_content_type->value) * 2 + 1;
-            char string[size];
-            BytesToStringBuffer(bstr_ptr(h_content_type->value), bstr_len(h_content_type->value), string, size);
-            char *p = strchr(string, ';');
+            uint32_t len = (uint32_t)bstr_len(h_content_type->value);
+            const uint8_t *p = memchr(bstr_ptr(h_content_type->value), ';', len);
             if (p != NULL)
-                *p = '\0';
-            jb_set_string(js, "http_content_type", string);
+                len = (uint32_t)(p - bstr_ptr(h_content_type->value));
+            jb_set_string_from_bytes(
+                    js, "http_content_type", bstr_ptr(h_content_type->value), len);
         }
         htp_header_t *h_content_range = htp_table_get_c(tx->response_headers, "content-range");
         if (h_content_range != NULL) {